
package com.library.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.Email;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.util.Date;

@ApiModel(description = "用户信息")
public class User {

    @ApiModelProperty(value = "用户ID", example = "1")
    private Integer userId;

    @ApiModelProperty(value = "用户名", example = "user123", required = true)
    @Pattern(regexp = "^(?=.*\\d)(?=.*[a-zA-Z])[a-zA-Z\\d]{6,10}$", message = "用户名应该是6-10位的数字和字母的组合")
    private String username;

    @ApiModelProperty(value = "密码", example = "pass123", required = true)
    @Pattern(regexp = "^(?=.*\\d)(?=.*[a-zA-Z])[a-zA-Z\\d]{6,10}$", message = "密码应该是6-10位的数字和字母的组合")
    private String password;

    @ApiModelProperty(value = "用户年龄", example = "25", required = true)
    @Range(min = 0, max = 150, message = "年龄应该在0-150之间")
    private Integer userAge;

    @ApiModelProperty(value = "用户生日", example = "1998-01-01", required = true)
    @Past(message = "生日不能大于当前日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date birthday;

    @ApiModelProperty(value = "用户邮箱", example = "user@example.com", required = true)
    @Email(message = "邮箱格式不正确")
    private String email;

    @ApiModelProperty(value = "用户头像路径", example = "/images/user1.jpg")
    private String headImg; // 用户头像的路径

    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Integer getUserAge() {
        return userAge;
    }

    public void setUserAge(Integer userAge) {
        this.userAge = userAge;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public User() {
    }
}